package com.hzcx.app.simplechat.ui.chat.presenter;

import android.app.Activity;
import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.bean.UpLoadImgBean;
import com.hzcx.app.simplechat.model.HomeModel;
import com.hzcx.app.simplechat.model.PublicModel;
import com.hzcx.app.simplechat.model.UserModel;
import com.hzcx.app.simplechat.ui.chat.bean.ChatCollectBean;
import com.hzcx.app.simplechat.ui.chat.contract.ChatCollectContract;
import com.hzcx.app.simplechat.ui.chat.contract.ChatContract;
import com.hzcx.app.simplechat.ui.user.bean.UserInfoBean;
import com.hzcx.app.simplechat.util.token.TokenUtils;

import java.util.List;

public class ChatCollectPresenter extends BasePresenter<ChatCollectContract.View> implements ChatCollectContract.Presenter {

    /**
     *  获取收藏列表
     * @param context
     * @param page
     */
    @Override
    public void getChatCollectList(Context context, int page) {
        HomeModel.getChatCollectList(context, page, new BaseObserver<List<ChatCollectBean>>() {
            @Override
            protected void onSuccess(List<ChatCollectBean> data) {
                mView.collectListResult(data);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {
                super.onFailure(e, errorMsg);
                mView.onFail();
            }
        });
    }

    /**
     *  删除收藏
     * @param context
     * @param id
     * @param pos
     */
    @Override
    public void deleteChatCollect(Context context, int id, int pos) {
        HomeModel.deleteChatCollect(context, id, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.deleteSuccess(pos);
            }
        });
    }
}
